package LexParser;

import java.util.ArrayList;
import java.util.List;

import LexParser.handlers.Handler;

import srw.Dictionary;
import srw.Word;

/**
 * Creates list of Word objects for different meanings of sentence word 
 * @see Word 
 *
 */

public class LexParser {

	private MystemParser _mystemParser;
	private Dictionary _dictionary;
	private List<Handler> _handlers = new ArrayList<Handler>(); 
	
	
	public List <Word> getWords(String string) {
		System.out.println("Lex parser get words: " + string);
		
		List<Word> result = new ArrayList<Word>();
		
		for (MystemWord mystemWord : _mystemParser.getMystemWords(string)) {
			for (Handler handler : _handlers) {
				//TODO treat null as an empty list
				List<Word> words = handler.getWords(mystemWord.getLemma(), mystemWord.getProprties());
				if (words != null)
					result.addAll(words);
			}
		}
		
		return result;
		
	}

	public void setMystemParser(MystemParser mystemParser) {
		_mystemParser = mystemParser;
	}

	public void addHandler(Handler handler) {
		_handlers.add(handler);
	}
	
}
